<template>
  <div class="login_box">
    <h2 style="color: #666">登录账号</h2>
    <p style="color: #666">虾米 — 严选商城欢迎您</p>
    <div class="login_input">
      <input type="text" v-model="mobile" placeholder="手机号码" class="login_input_inp">

    </div>
    <div class="login_input">
      <input type="password" v-model="password" placeholder="密码" class="login_input_inp">

    </div>
    <div class="login_btn" @click="login">登 录</div>
    <p class="login_reset">忘记密码</p>
    <p class="login_enroll" @click="gotoreg">还没有注册？ 立即注册</p>



  </div>
</template>

<script>
  import Vue from 'vue';
  import {
    Toast
  } from 'vant';

  Vue.use(Toast);
  export default {
    data() {
      return {
        mobile: '',
        password: '',
      }
    },

    methods: {
      login() {
        // console.log(this.mobile);
        this.$API.user_login(this.mobile, this.password).then((res) => {
          // console.log(res);
          if (this.mobile == "13500000000" && this.password != "") {
            Toast({
              message: '登录成功！',
              position: 'top',
            });
            localStorage.setItem("token", res.data.data.token)

          } else {
            Toast({
              message: '账号或密码错误！',
              position: 'top',
            });

          }
        }).catch((err) => {
          console.log(err);
        });
      },
      gotoreg(){
        this.$router.push('/reg')
      }

    },

  }
</script>

<style lang="scss" scoped>
  .login_box {
    width: 70%;
    margin: 15%;
  }

  .login_input {
    width: 100%;
    height: 6vh;
    margin: 2vh 0;
    border-radius: 10px;
    background-color: #F5F5F5;
    display: flex;
    justify-content: space-around;
    align-items: center;
    overflow: hidden;
    font-size: 14px;
  }

  .login_input_inp {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    color: #666;
    background-color: #F5F5F5;
  }

  .login_input_icon {
    width: 45%;
    height: 100%;
    background-color: #F5F5F5;
  }

  .login_btn {
    width: 80%;
    height: 7vh;
    font-size: 0.6rem;
    margin: 10%;
    color: #fff;
    text-align: center;
    line-height: 7vh;
    background: linear-gradient(135deg, #e570e7 0%, #79f1fc 100%);
    box-shadow: 0 5px 3px rgba(0, 0, 0, 0.3);
    -webkit-tap-highlight-color: transparent;
    border-radius: 0.1rem;
  }

  .login_reset {
    font-size: 0.2rem;
    color: #666;
    text-align: center;
  }

  .login_enroll {
    margin: 2vh;
    font-size: 12px;
    color: skyblue;
    text-align: center;
    font-weight: bold;
  }
</style>